package edu.ynu.se.xiecheng.achitectureclass.entity;

import edu.ynu.se.xiecheng.achitectureclass.common.entity.LogicEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

//大棚信息
@Entity
@Table(name = "greenhouse")
@Data
@EqualsAndHashCode(callSuper = true, exclude = "devices")
@ToString(exclude = "devices")
public class Greenhouse extends LogicEntity {

    @Column(name = "name", nullable = false, length = 255)
    private String name; // 大棚名称，非空，最长255字符

    @Column(name = "address", nullable = false, length = 500)
    private String address; // 大棚地址，非空，最长500字符

    @Column(name = "area", nullable = false)
    private Double area; // 大棚面积，非空

    @OneToMany(mappedBy = "greenhouse", fetch = FetchType.EAGER)
    private Set<Device> devices = new HashSet<>();
}